/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { ViewProps, HostComponent } from 'react-native';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type {
  Float,
  DirectEventHandler,
} from 'react-native/Libraries/Types/CodegenTypes';

export interface HoverEvent {
  isHover: boolean;
  type: string;
}

export interface GestureEvent {
  type: string;
  repeat: boolean;
  offsetX: Float;
  offsetY: Float;
  angle: Float;
  scale: Float;
  pinchCenterX: Float;
  pinchCenterY: Float;
  speed: Float;
  fingerList: Float[][]; 
  velocityX: Float;
  velocityY: Float;
  velocity: Float;
  timestamp: Float;
  source: Float;
  rollAngle: Float;
  sourceTool: Float;
  axisHorizontal: Float;
  axisVertical: Float;
  deviceId: Float; 
  targetDisplayId: Float;
}
 
export interface NativeProps extends ViewProps {
  fingers?: Float, // 触发手势的最小手指数量
  direction?: string, // 手势方向，可能的值有：'all', 'horizontal', 'vertical', 'left', 'right', 'up', 'down', 'none'
  minDistance?: Float, // 手势触发的最小距离, 滚动、单击、双击、缩放
  minVelocity?: Float, // 手势触发的最小速度, 轻扫
  gestureType?: string, // 手势类型，轻扫、滑动、单击、双击、长按、旋转、缩放、悬停或者混合
  numberOfTaps?: Float, // 手势触发的最小点击次数， 单击、双击、三击
  minDurationMs?: Float, // 手势触发的最小持续时间（毫秒）, 长按
  minAngle?: Float, // 手势触发的最小角度, 旋转
  repeat?: boolean, // 是否重复触发手势事件, 长按
  isMultiGesture?: boolean, // 是否是组合手势
  multiGestureType?: string, // 组合手势类型，可能的值有：'sequence', 'parallel', 'exclusive'
  multiGestures?: string[], // 组合手势的手势序列，可能的值有：'tap', 'longPress', 'pan', 'rotation', 'pinch', 'fling', 'hover'
  onGestureStart?: DirectEventHandler<GestureEvent>;
  onGestureUpdate?: DirectEventHandler<GestureEvent>;
  onGestureEnd?: DirectEventHandler<GestureEvent>;
  onGestureCancel?: DirectEventHandler<GestureEvent>;
  onHover?: DirectEventHandler<HoverEvent>;
}

export default codegenNativeComponent<NativeProps>(
  'GestureEventsView',
) as HostComponent<NativeProps>;